<?php use_helper('jQuery')?>
<div id="main_header" class="ui-widget-header ui-corner-all">
    <h3>Datos del Banner: "<?php echo $element->getTitle() ?>""</h3>
</div>
<div id="main_content" class="ui-widget ui-widget-content ui-corner-all">
    <table>
        <?php if($sf_user->hasCredential('Editar elemento')): ?>
            <tfoot>
                <tr>
                    <td colspan="2">
                        <?php echo jq_link_to_remote(
                                '<span class="ui-button-icon-primary ui-icon ui-icon-pencil"></span>
                                <span class="ui-button-text">Editar</span>',
                            array(
                                'update' => 'main',
                                'url' => url_for('element_edit',$element),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            ), array(
                                'class' => 'ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary',
                                'title' => 'Editar'
                            )) ?>
                    </td>
                </tr>
            </tfoot>
        <?php endif; ?>
        <tbody>
            <?php if(!$element->getHeaderId() && !$element->getFooterId()) :?>
                <tr>
                    <th>Sección:</th>
                    <td>
                        <?php echo jq_link_to_remote(
                                $element->getSection(),
                            array(
                                'update' => 'main',
                                'url' => url_for('section_show',$element->getSection()),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            )) ?>
                    </td>
                </tr>
            <?php endif; ?>
            <tr>
                <th>Posición:</th>
                <td><?php echo $element->getPosition()?></td>
            </tr>
            <tr>
                <th>Con link:</th>
                <td>
                    <?php if ($element->getBanner()->getIsLocal()): ?>
                        Local
                    <?php else: ?>
                        Externo
                    <?php endif; ?>
                </td>
            </tr>
            <?php if ($element->getBanner()->getIsLocal()): ?>
                <tr>
                    <th>Dirige a: </th>
                    <td>
                        <?php echo jq_link_to_remote(
                                $element->getBanner()->getSection(),
                            array(
                                'update' => 'main',
                                'url' => url_for('section_show',$element->getBanner()->getSection()),
                                'before' => 'clearView();showLoaderMain();',
                                'complete' => 'hideLoader();',
                                'script' => true
                            )) ?>
                    </td>
                </tr>
            <?php else: ?>
                <tr>
                    <th>URL: </th>
                    <td>
                        <a href="<?php echo $element->getBanner()->getLink()?>" target="_blank">
                            <?php echo $element->getBanner()->getLink()?>
                        </a>
                    </td>
                </tr>
            <?php endif; ?>
            <tr>
                <th colspan="2">Imagenes: </th>
            </tr>
            <tr>
                <th>Tamaño (px)</th>
                <th>Imagen</th>
            </tr>
                <?php foreach ($element->getBanner()->getImages() as $image):?>
                    <tr>
                        <th><?php echo $image->getSize()?></th>
                        <?php if(!$element->getHeaderId() && !$element->getFooterId()) :?>
                            <td><img  alt="<?php echo $image->getFile()?>"
                                 src="<?php echo '/uploads/portal_'.$element->getSection()->getPortalId().'/images/'.$image->getFile()?>">
                            </td>
                        <?php else: ?>
                            <?php if($element->getHeaderId()): ?>
                                <td><img  alt="<?php echo $image->getFile()?>"
                                     src="<?php echo '/uploads/portal_'.$element->getHeader()->getPortalId().'/images/'.$image->getFile()?>">
                                </td>
                            <?php else: ?>
                                <td><img  alt="<?php echo $image->getFile()?>"
                                     src="<?php echo '/uploads/portal_'.$element->getFooter()->getPortalId().'/images/'.$image->getFile()?>">
                                </td>
                            <?php endif; ?>
                        <?php endif;?>
                    </tr>
                <?php endforeach;?>
            <tr>
                <th>Publicado:</th>
                <td>
                    <?php if ($element->getPublished() == true): ?>
                        <img alt="Sí" src="/images/util/check.png">
                    <?php else: ?>
                        <img alt="No" src="/images/util/cross.png">
                    <?php endif; ?>
                </td>
            </tr>
            <tr>
                <th>Fecha de creación:</th>
                <td><?php echo $element->getDateTimeObject('created_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
            <tr>
                <th><label>Ultima modificación:</label></th>
                <td><?php echo $element->getDateTimeObject('updated_at')->format('d/m/Y - g:i a') ?></td>
            </tr>
        </tbody>
    </table>
</div>